package com.innovation.chengzhangriji.ui.widget;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.innovation.chengzhangriji.Config;
import com.innovation.chengzhangriji.R;
import com.makeramen.roundedimageview.RoundedImageView;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

public class CommentVideoView extends FrameLayout {

    private RoundedImageView mImage;
    private TextView mText;

    public CommentVideoView(Context context) {
        super(context);
        initView(context);
    }

    public CommentVideoView(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public CommentVideoView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initView(context);
    }

    // 初始化
    private void initView(Context context) {
        LayoutInflater.from(context).inflate(R.layout.item_comment_video, this);
        mImage = (RoundedImageView) findViewById(R.id.thumb_video);
        mText = (TextView) findViewById(R.id.txt_video_dur);
    }

    /**
     * 设置视频缩略图的 Url
     * @param thumbUrl
     */
    public void setVideoImageUrl(String thumbUrl) {
        ImageLoader.getInstance().displayImage(thumbUrl, mImage, Config.getOptionsPhoto(), null);
    }

    public void setVideoDuration(String duration) {
        mText.setText(duration + "''");
    }
}
